package com.ec.activemq.contorller;

import cn.hutool.core.date.DateTime;
import com.ec.core.activemq.utils.ActiveMqUtil;
import com.ec.core.common.core.api.ResponseMsg;
import com.ec.core.common.core.api.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.jms.Queue;
import javax.jms.Topic;

/**
 * @author Eric Lee
 * @since 2022-07-11 15:59
 */
@Slf4j
@RestController
@RequestMapping("test")
public class TestController {

    @Resource
    private Queue queue;

    @Resource
    private Topic topic;

    @GetMapping("/queue")
    public Result<Void> sendQueue() {
        ActiveMqUtil.sendQueueMessage(queue, "测试queue-String:" + new DateTime());
        return ResponseMsg.success();
    }

    @GetMapping("/topic")
    public Result<Void> sendTopic() {
        ActiveMqUtil.sendTopicMessage(topic, "测试topic-String" + new DateTime());
        return ResponseMsg.success();
    }

}
